-
Notifications
You must be signed in to change notification settings - Fork 8k
posix: clock: fix maybe-uninitialized warning in z_clock_gettime #89928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@cfriedt any chance you could also look into the other issue please?
Setting |
lib/posix/options/clock_common.c
Outdated
int z_clock_gettime(clockid_t clock_id, struct timespec *ts) | ||
{ | ||
struct timespec base; | ||
struct timespec base = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This made L66 and 67 unnecessary, should we remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree with that - can you make that change, @kartben?
Monotonic is a bit of a hot path, so removing the additional 2+ memory writes would be a good thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move 66-67 before the switch, keep it explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
66-67 shouldn't be needed with the variable initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check the updated fix
That's a good short-term solution. I can make that change shortly. I think the issue is that some libc functions use POSIX functions (maybe indirectly?). Mentioned in #89068 as well. Long term, I think it would be great to move some things into native Zephyr code. |
Compiler gets confused and thinks base may be used uninitialized. This shouldn't be possible, but to make the warning go away, initialize it. Signed-off-by: Benjamin Cabé <[email protected]>
f075a5e
to
552e900
Compare
Compiler gets confused and thinks base may be used uninitialized. This shouldn't be possible, but to make the warning go away, initialize it.
Fixes CI issue in main https://github.com/zephyrproject-rtos/zephyr/actions/runs/15014534061/job/42189411225